<template>
<view class="list">
    <view class="list-item">
        <view class="list-item-title">
            <view class="list-item-title-head">邀请工友获取积分</view>
            <view class="list-item-title-content">没成功邀请一位工友注册，可获得积分。（推荐）</view>
        </view>
        <view class="list-item-share">
            <button type="primary" open-type="share">去邀请</button>
        </view>
    </view>
    <view class="list-item">
        <view class="list-item-title">
            <view class="list-item-title-head">玩游戏赚积分</view>
            <view class="list-item-title-content">玩游戏，每天可以获得1-300分。（推荐）</view>
        </view>
        <view class="list-item-share">
            <button type="primary" @tap="game">去看看</button>
        </view>
    </view>
    <view class="list-item-help">
        <view class="list-item-title">
            <view class="list-item-help-title">温馨提示</view>
            <view class="list-item-title-content">
                如果有任何疑问，请联系我们。我们投入人力人力物力开发平台、审核信息、免费服务千万工友。因此请大家帮忙多邀请共有注册，感谢您对我们的支持！
            </view>
        </view>
    </view>
</view>
</template>

<script>
// pages/common/share/share.js
let app = getApp();

export default {
  data() {
    return {
      userInfo: {}
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.onGetUserInfo();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target);
    }

    return {
      title: '全国建筑工地招工服务平台',
      path: `/pages/card/square/square?r=${this.userInfo.id}`
    };
  },
  methods: {
    game(e) {
      uni.showToast({
        title: '正在扩展中',
        complete: res => {},
        fail: res => {},
        icon: "none",
        success: res => {}
      });
    },

    onGetUserInfo() {
      let openid = uni.getStorageSync('openid');

      let _this = this;

      if (!openid) {
        uni.navigateBack({
          complete: res => {
            uni.showToast({
              title: '请登录',
              icon: "none"
            });
          }
        });
      } else {
        uni.request({
          url: `${app.globalData.baseUrl}/user/selectIsUser/${openid}`,
          complete: res => {},
          success: result => {
            _this.setData({
              userInfo: result.data.dataMap.data
            });
          }
        });
      }
    }

  }
};
</script>
<style>
/* pages/common/share/share.wxss */
.list {
    width: 96%;
    margin: 2%;
}

.list-item {
    margin-top: 10rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10rpx 20rpx;
    background: #ffffff;
}

.list-item-title {
    flex: 7;
}

.list-item-title-head {
    color: black;
    font-size: 40rpx;
}

.list-item-title-content {
    color: grey;
}

.list-item-share {
    flex: 3;
}

.list-item-help {
    margin-top: 20rpx;
    padding: 10rpx 20rpx;
    background: #ffffff;
}

.list-item-help-title {
    color: #19a918;
    font-size: 40rpx;
    text-align: center;
    margin: 20rpx 0rpx;
}
</style>